<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">

<title>电子文档系统</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<script type="text/javascript" src="view/jquery/jquery-1.9.1.js"></script>
<script type="text/javascript" src="view/bootstrap/js/bootstrap.js"></script>
<link rel="stylesheet" href="view/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="view/css/docMan.css">
<link rel="stylesheet" href="view/css/font-awesome.min.css">
<link rel="stylesheet" href="view/css/buttons.css">
<link rel="stylesheet" href="view/toastr/toastr.css">
<script type="text/javascript" src="view/js/docMan.js"></script>
<script type="text/javascript" src="view/toastr/toastr.min.js"></script>
<script type="text/javascript" src="view/js/ajaxfileupload.js"></script>
</head>
<body style="background: #EDEFF0;">
	<div id="main-container" class="container"
		style="height: 100%;width:100%;background: #EDEFF0;padding-top:20px;">
		<div class="row" style="width:80%;margin-left:10%">
			<button class="btn btn-primary"  id="addType">添加</button>
		</div>
		<div class="row bookTypeList" style="width:80%;margin-left:10%">
			<table class="table ">
				<thead>
					<tr>
						<th class="col-md-5">分类</th>
						<th class="col-md-4">创建时间</th>
						<th class="col-md-3">操作</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator  value="docTypes" id="type" status="stu">
						<tr >
							<td class="hand" id='<s:property value="#type.id" />'><s:property value="#type.typeName" /> </td>	
							<td><s:date name="#type.createTime" format="yyyy-MM-dd"/> </td>
							<td><button value='<s:property value="#type.id" />' class="btn btn-primary typeEdit">编辑</button>
							<button value='<s:property value="#type.id" />'  class="btn btn-danger typeDel" >删除</button></td>
						</tr>
					</s:iterator>
				</tbody>
			</table>	
		</div>
		
	</div>








<div class="modal fade" id="addTypeModal" tabindex="-1" role="dialog"
		aria-labelledby="exampleModalLabel">
		<div class="modal-dialog" role="document" >
			<form >
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title" id="boolTitle">新建分类</h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
							<label for="bookName" class="control-label">分类名:</label> <input
								type="text" class="form-control" id="typeName">
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" id="btn_addType" class="btn btn-primary">添加</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	
</body>

<script type="text/javascript">
	$(function(){
		$("#addType").on("click",function(){
			$("#addTypeModal").modal("show");
		});
		$("#btn_addType").on("click",function(){
			var name=$("#typeName").val().trim();
			 $.ajax({
			 type:"post",
			 url:"/DocMan/webService/show/DocType/addDocType",
			 data:{typeName:name,id:0},
			 traditional:true,
			 success:function(data){
				refresh();
			 },
			 error:function(data){
				 toast.error("创建网盘错误", "温馨提示");
			 }
		  });
		});
		$(".hand").on("click",function(){
			var typeId=$(this).attr("id");
			window.location.href="book.action?typeId="+typeId;
		});
	});
</script>
</html>
